{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sqlalchemy.engine import create_engine"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import os"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "os.chdir(r'D:\\2005\\day48\\bayer\\data\\驱虫剂市场')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "import glob"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [],
   "source": [
    "files = glob.glob('*近三年交易额.xlsx')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 6,
   "metadata": {},
   "outputs": [],
   "source": [
    "import re"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 7,
   "metadata": {},
   "outputs": [],
   "source": [
    "def read_data(file_name):\n",
    "    print(file_name)\n",
    "    temp = pd.read_excel(file_name)\n",
    "    # 只有时间类型是int64的才需要做转换\n",
    "    if temp.时间.dtype == 'int64':\n",
    "        temp['时间'] = pd.to_datetime(temp['时间'], unit='D', origin='1899-12-30')\n",
    "        \n",
    "    temp.set_index('时间', inplace=True)\n",
    "    colname = re.match(r'.*?(?=市场)', file_name).group()\n",
    "    temp.columns = [colname]\n",
    "    return temp"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 8,
   "metadata": {
    "scrolled": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "灭鼠杀虫剂市场近三年交易额.xlsx\n",
      "电蚊香套装市场近三年交易额.xlsx\n",
      "盘香灭蟑香蚊香盘市场近三年交易额.xlsx\n",
      "蚊香加热器市场近三年交易额.xlsx\n",
      "蚊香液市场近三年交易额.xlsx\n",
      "蚊香片市场近三年交易额.xlsx\n",
      "防霉防蛀片市场近三年交易额.xlsx\n"
     ]
    }
   ],
   "source": [
    "temps = []\n",
    "for file_name in files:\n",
    "    temp = read_data(file_name)\n",
    "    temps.append(temp)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "df = pd.concat(temps, axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.reset_index(inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>时间</th>\n",
       "      <th>灭鼠杀虫剂</th>\n",
       "      <th>电蚊香套装</th>\n",
       "      <th>盘香灭蟑香蚊香盘</th>\n",
       "      <th>蚊香加热器</th>\n",
       "      <th>蚊香液</th>\n",
       "      <th>蚊香片</th>\n",
       "      <th>防霉防蛀片</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-10-01</td>\n",
       "      <td>1.136548e+08</td>\n",
       "      <td>106531.29</td>\n",
       "      <td>4171283.35</td>\n",
       "      <td>315639.48</td>\n",
       "      <td>7.814546e+06</td>\n",
       "      <td>1032414.29</td>\n",
       "      <td>8541153.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-09-01</td>\n",
       "      <td>1.440261e+08</td>\n",
       "      <td>105666.63</td>\n",
       "      <td>6784500.17</td>\n",
       "      <td>457366.41</td>\n",
       "      <td>1.065497e+07</td>\n",
       "      <td>1566651.88</td>\n",
       "      <td>8825870.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-08-01</td>\n",
       "      <td>1.540426e+08</td>\n",
       "      <td>201467.03</td>\n",
       "      <td>10709683.41</td>\n",
       "      <td>746513.13</td>\n",
       "      <td>1.783558e+07</td>\n",
       "      <td>2617149.00</td>\n",
       "      <td>6320153.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-07-01</td>\n",
       "      <td>1.480032e+08</td>\n",
       "      <td>438635.29</td>\n",
       "      <td>16589184.89</td>\n",
       "      <td>1871757.00</td>\n",
       "      <td>3.887792e+07</td>\n",
       "      <td>6209040.06</td>\n",
       "      <td>6302595.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-06-01</td>\n",
       "      <td>1.359438e+08</td>\n",
       "      <td>953749.78</td>\n",
       "      <td>23526385.73</td>\n",
       "      <td>3641025.92</td>\n",
       "      <td>7.649909e+07</td>\n",
       "      <td>12484919.63</td>\n",
       "      <td>7047206.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2018-05-01</td>\n",
       "      <td>1.241642e+08</td>\n",
       "      <td>1238967.37</td>\n",
       "      <td>28118581.25</td>\n",
       "      <td>5032466.78</td>\n",
       "      <td>1.050396e+08</td>\n",
       "      <td>15309721.94</td>\n",
       "      <td>7942340.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018-04-01</td>\n",
       "      <td>7.509661e+07</td>\n",
       "      <td>841051.93</td>\n",
       "      <td>16420341.87</td>\n",
       "      <td>3130513.43</td>\n",
       "      <td>6.254165e+07</td>\n",
       "      <td>7954875.07</td>\n",
       "      <td>7031364.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2018-03-01</td>\n",
       "      <td>5.918182e+07</td>\n",
       "      <td>475177.48</td>\n",
       "      <td>7900094.91</td>\n",
       "      <td>1198332.81</td>\n",
       "      <td>2.632447e+07</td>\n",
       "      <td>2950648.32</td>\n",
       "      <td>6051561.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2018-02-01</td>\n",
       "      <td>2.292138e+07</td>\n",
       "      <td>33232.95</td>\n",
       "      <td>545917.66</td>\n",
       "      <td>75714.46</td>\n",
       "      <td>2.235774e+06</td>\n",
       "      <td>218915.63</td>\n",
       "      <td>1393948.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>3.653873e+07</td>\n",
       "      <td>54305.20</td>\n",
       "      <td>592663.20</td>\n",
       "      <td>86670.45</td>\n",
       "      <td>1.759451e+06</td>\n",
       "      <td>298146.11</td>\n",
       "      <td>2607776.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2017-12-01</td>\n",
       "      <td>4.292283e+07</td>\n",
       "      <td>71600.17</td>\n",
       "      <td>796930.46</td>\n",
       "      <td>69145.59</td>\n",
       "      <td>2.213103e+06</td>\n",
       "      <td>314120.38</td>\n",
       "      <td>3259747.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2017-11-01</td>\n",
       "      <td>5.838217e+07</td>\n",
       "      <td>94993.76</td>\n",
       "      <td>1581530.20</td>\n",
       "      <td>168141.79</td>\n",
       "      <td>4.257594e+06</td>\n",
       "      <td>617094.94</td>\n",
       "      <td>5447184.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2017-10-01</td>\n",
       "      <td>8.226882e+07</td>\n",
       "      <td>145925.31</td>\n",
       "      <td>2824785.80</td>\n",
       "      <td>166522.62</td>\n",
       "      <td>4.290843e+06</td>\n",
       "      <td>766588.77</td>\n",
       "      <td>6152868.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2017-09-01</td>\n",
       "      <td>1.010081e+08</td>\n",
       "      <td>242194.37</td>\n",
       "      <td>5581352.42</td>\n",
       "      <td>353042.45</td>\n",
       "      <td>7.833349e+06</td>\n",
       "      <td>1574779.65</td>\n",
       "      <td>5792065.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2017-08-01</td>\n",
       "      <td>1.049504e+08</td>\n",
       "      <td>332922.02</td>\n",
       "      <td>7229409.84</td>\n",
       "      <td>544076.63</td>\n",
       "      <td>1.376039e+07</td>\n",
       "      <td>2323304.14</td>\n",
       "      <td>5081714.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2017-07-01</td>\n",
       "      <td>1.116729e+08</td>\n",
       "      <td>913425.95</td>\n",
       "      <td>13718046.88</td>\n",
       "      <td>1357778.93</td>\n",
       "      <td>4.257757e+07</td>\n",
       "      <td>6627299.71</td>\n",
       "      <td>6691694.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2017-06-01</td>\n",
       "      <td>1.051463e+08</td>\n",
       "      <td>2045163.59</td>\n",
       "      <td>19635925.59</td>\n",
       "      <td>2639777.66</td>\n",
       "      <td>8.283230e+07</td>\n",
       "      <td>12422420.21</td>\n",
       "      <td>7155138.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2017-05-01</td>\n",
       "      <td>9.185035e+07</td>\n",
       "      <td>3606141.82</td>\n",
       "      <td>20275515.85</td>\n",
       "      <td>3185961.75</td>\n",
       "      <td>1.014605e+08</td>\n",
       "      <td>15961946.71</td>\n",
       "      <td>8145781.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2017-04-01</td>\n",
       "      <td>5.363586e+07</td>\n",
       "      <td>1285599.49</td>\n",
       "      <td>9197868.29</td>\n",
       "      <td>1554864.42</td>\n",
       "      <td>4.880687e+07</td>\n",
       "      <td>6214963.68</td>\n",
       "      <td>6682161.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2017-03-01</td>\n",
       "      <td>4.078967e+07</td>\n",
       "      <td>390486.57</td>\n",
       "      <td>3397837.60</td>\n",
       "      <td>317206.48</td>\n",
       "      <td>1.488979e+07</td>\n",
       "      <td>1319399.22</td>\n",
       "      <td>3904656.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2017-02-01</td>\n",
       "      <td>3.467502e+07</td>\n",
       "      <td>209643.87</td>\n",
       "      <td>1519446.34</td>\n",
       "      <td>148158.07</td>\n",
       "      <td>5.929509e+06</td>\n",
       "      <td>687697.46</td>\n",
       "      <td>2584035.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>2.047156e+07</td>\n",
       "      <td>39434.76</td>\n",
       "      <td>596744.04</td>\n",
       "      <td>48164.63</td>\n",
       "      <td>1.213749e+06</td>\n",
       "      <td>238973.09</td>\n",
       "      <td>1781773.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2016-12-01</td>\n",
       "      <td>3.546668e+07</td>\n",
       "      <td>84350.57</td>\n",
       "      <td>1234900.05</td>\n",
       "      <td>52118.96</td>\n",
       "      <td>1.558634e+06</td>\n",
       "      <td>293737.20</td>\n",
       "      <td>3504367.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2016-11-01</td>\n",
       "      <td>4.780625e+07</td>\n",
       "      <td>106291.23</td>\n",
       "      <td>1473418.20</td>\n",
       "      <td>82835.82</td>\n",
       "      <td>2.758827e+06</td>\n",
       "      <td>512990.23</td>\n",
       "      <td>4975519.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2016-10-01</td>\n",
       "      <td>6.339722e+07</td>\n",
       "      <td>179015.23</td>\n",
       "      <td>2543813.78</td>\n",
       "      <td>130484.07</td>\n",
       "      <td>3.641803e+06</td>\n",
       "      <td>690912.02</td>\n",
       "      <td>4600717.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2016-09-01</td>\n",
       "      <td>6.864724e+07</td>\n",
       "      <td>210456.69</td>\n",
       "      <td>3092898.02</td>\n",
       "      <td>168724.83</td>\n",
       "      <td>4.632818e+06</td>\n",
       "      <td>930513.91</td>\n",
       "      <td>4642681.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2016-08-01</td>\n",
       "      <td>7.610885e+07</td>\n",
       "      <td>316467.14</td>\n",
       "      <td>4389862.79</td>\n",
       "      <td>272553.95</td>\n",
       "      <td>8.956868e+06</td>\n",
       "      <td>1581021.50</td>\n",
       "      <td>4151326.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>7.832954e+07</td>\n",
       "      <td>932728.10</td>\n",
       "      <td>7384968.66</td>\n",
       "      <td>761159.35</td>\n",
       "      <td>2.260036e+07</td>\n",
       "      <td>4088320.77</td>\n",
       "      <td>5412185.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2016-06-01</td>\n",
       "      <td>7.693264e+07</td>\n",
       "      <td>2184985.33</td>\n",
       "      <td>10859461.67</td>\n",
       "      <td>1728788.53</td>\n",
       "      <td>4.640197e+07</td>\n",
       "      <td>8004562.69</td>\n",
       "      <td>5694825.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2016-05-01</td>\n",
       "      <td>5.812696e+07</td>\n",
       "      <td>2059879.80</td>\n",
       "      <td>9912801.93</td>\n",
       "      <td>1618361.54</td>\n",
       "      <td>4.777690e+07</td>\n",
       "      <td>7474421.97</td>\n",
       "      <td>5469360.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2016-04-01</td>\n",
       "      <td>3.762602e+07</td>\n",
       "      <td>1034992.53</td>\n",
       "      <td>4687913.18</td>\n",
       "      <td>758206.81</td>\n",
       "      <td>2.432917e+07</td>\n",
       "      <td>3435257.35</td>\n",
       "      <td>5253619.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2016-03-01</td>\n",
       "      <td>2.952610e+07</td>\n",
       "      <td>352013.31</td>\n",
       "      <td>1204574.20</td>\n",
       "      <td>246106.75</td>\n",
       "      <td>6.656382e+06</td>\n",
       "      <td>746709.07</td>\n",
       "      <td>3481194.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>1.500135e+07</td>\n",
       "      <td>96979.48</td>\n",
       "      <td>449199.41</td>\n",
       "      <td>36193.85</td>\n",
       "      <td>6.939075e+05</td>\n",
       "      <td>109108.05</td>\n",
       "      <td>1274810.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2016-01-01</td>\n",
       "      <td>2.107822e+07</td>\n",
       "      <td>108412.71</td>\n",
       "      <td>619042.01</td>\n",
       "      <td>49670.25</td>\n",
       "      <td>4.828890e+05</td>\n",
       "      <td>113284.71</td>\n",
       "      <td>1562393.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2015-12-01</td>\n",
       "      <td>2.472756e+07</td>\n",
       "      <td>110068.83</td>\n",
       "      <td>818479.56</td>\n",
       "      <td>34076.91</td>\n",
       "      <td>5.832845e+05</td>\n",
       "      <td>134890.48</td>\n",
       "      <td>2333602.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2015-11-01</td>\n",
       "      <td>3.303873e+07</td>\n",
       "      <td>185094.22</td>\n",
       "      <td>1197791.27</td>\n",
       "      <td>86889.91</td>\n",
       "      <td>1.579796e+06</td>\n",
       "      <td>325744.43</td>\n",
       "      <td>3364112.14</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           时间         灭鼠杀虫剂       电蚊香套装     盘香灭蟑香蚊香盘       蚊香加热器  \\\n",
       "0  2018-10-01  1.136548e+08   106531.29   4171283.35   315639.48   \n",
       "1  2018-09-01  1.440261e+08   105666.63   6784500.17   457366.41   \n",
       "2  2018-08-01  1.540426e+08   201467.03  10709683.41   746513.13   \n",
       "3  2018-07-01  1.480032e+08   438635.29  16589184.89  1871757.00   \n",
       "4  2018-06-01  1.359438e+08   953749.78  23526385.73  3641025.92   \n",
       "5  2018-05-01  1.241642e+08  1238967.37  28118581.25  5032466.78   \n",
       "6  2018-04-01  7.509661e+07   841051.93  16420341.87  3130513.43   \n",
       "7  2018-03-01  5.918182e+07   475177.48   7900094.91  1198332.81   \n",
       "8  2018-02-01  2.292138e+07    33232.95    545917.66    75714.46   \n",
       "9  2018-01-01  3.653873e+07    54305.20    592663.20    86670.45   \n",
       "10 2017-12-01  4.292283e+07    71600.17    796930.46    69145.59   \n",
       "11 2017-11-01  5.838217e+07    94993.76   1581530.20   168141.79   \n",
       "12 2017-10-01  8.226882e+07   145925.31   2824785.80   166522.62   \n",
       "13 2017-09-01  1.010081e+08   242194.37   5581352.42   353042.45   \n",
       "14 2017-08-01  1.049504e+08   332922.02   7229409.84   544076.63   \n",
       "15 2017-07-01  1.116729e+08   913425.95  13718046.88  1357778.93   \n",
       "16 2017-06-01  1.051463e+08  2045163.59  19635925.59  2639777.66   \n",
       "17 2017-05-01  9.185035e+07  3606141.82  20275515.85  3185961.75   \n",
       "18 2017-04-01  5.363586e+07  1285599.49   9197868.29  1554864.42   \n",
       "19 2017-03-01  4.078967e+07   390486.57   3397837.60   317206.48   \n",
       "20 2017-02-01  3.467502e+07   209643.87   1519446.34   148158.07   \n",
       "21 2017-01-01  2.047156e+07    39434.76    596744.04    48164.63   \n",
       "22 2016-12-01  3.546668e+07    84350.57   1234900.05    52118.96   \n",
       "23 2016-11-01  4.780625e+07   106291.23   1473418.20    82835.82   \n",
       "24 2016-10-01  6.339722e+07   179015.23   2543813.78   130484.07   \n",
       "25 2016-09-01  6.864724e+07   210456.69   3092898.02   168724.83   \n",
       "26 2016-08-01  7.610885e+07   316467.14   4389862.79   272553.95   \n",
       "27 2016-07-01  7.832954e+07   932728.10   7384968.66   761159.35   \n",
       "28 2016-06-01  7.693264e+07  2184985.33  10859461.67  1728788.53   \n",
       "29 2016-05-01  5.812696e+07  2059879.80   9912801.93  1618361.54   \n",
       "30 2016-04-01  3.762602e+07  1034992.53   4687913.18   758206.81   \n",
       "31 2016-03-01  2.952610e+07   352013.31   1204574.20   246106.75   \n",
       "32 2016-02-01  1.500135e+07    96979.48    449199.41    36193.85   \n",
       "33 2016-01-01  2.107822e+07   108412.71    619042.01    49670.25   \n",
       "34 2015-12-01  2.472756e+07   110068.83    818479.56    34076.91   \n",
       "35 2015-11-01  3.303873e+07   185094.22   1197791.27    86889.91   \n",
       "\n",
       "             蚊香液          蚊香片       防霉防蛀片  \n",
       "0   7.814546e+06   1032414.29  8541153.59  \n",
       "1   1.065497e+07   1566651.88  8825870.43  \n",
       "2   1.783558e+07   2617149.00  6320153.44  \n",
       "3   3.887792e+07   6209040.06  6302595.06  \n",
       "4   7.649909e+07  12484919.63  7047206.98  \n",
       "5   1.050396e+08  15309721.94  7942340.44  \n",
       "6   6.254165e+07   7954875.07  7031364.60  \n",
       "7   2.632447e+07   2950648.32  6051561.02  \n",
       "8   2.235774e+06    218915.63  1393948.47  \n",
       "9   1.759451e+06    298146.11  2607776.07  \n",
       "10  2.213103e+06    314120.38  3259747.23  \n",
       "11  4.257594e+06    617094.94  5447184.43  \n",
       "12  4.290843e+06    766588.77  6152868.25  \n",
       "13  7.833349e+06   1574779.65  5792065.80  \n",
       "14  1.376039e+07   2323304.14  5081714.64  \n",
       "15  4.257757e+07   6627299.71  6691694.17  \n",
       "16  8.283230e+07  12422420.21  7155138.87  \n",
       "17  1.014605e+08  15961946.71  8145781.12  \n",
       "18  4.880687e+07   6214963.68  6682161.49  \n",
       "19  1.488979e+07   1319399.22  3904656.82  \n",
       "20  5.929509e+06    687697.46  2584035.90  \n",
       "21  1.213749e+06    238973.09  1781773.46  \n",
       "22  1.558634e+06    293737.20  3504367.98  \n",
       "23  2.758827e+06    512990.23  4975519.21  \n",
       "24  3.641803e+06    690912.02  4600717.78  \n",
       "25  4.632818e+06    930513.91  4642681.07  \n",
       "26  8.956868e+06   1581021.50  4151326.68  \n",
       "27  2.260036e+07   4088320.77  5412185.06  \n",
       "28  4.640197e+07   8004562.69  5694825.13  \n",
       "29  4.777690e+07   7474421.97  5469360.60  \n",
       "30  2.432917e+07   3435257.35  5253619.06  \n",
       "31  6.656382e+06    746709.07  3481194.46  \n",
       "32  6.939075e+05    109108.05  1274810.96  \n",
       "33  4.828890e+05    113284.71  1562393.95  \n",
       "34  5.832845e+05    134890.48  2333602.08  \n",
       "35  1.579796e+06    325744.43  3364112.14  "
      ]
     },
     "execution_count": 11,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [],
   "source": [
    "from sklearn.linear_model import LinearRegression"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "import datetime"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "from pandas import DataFrame"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [],
   "source": [
    "for month in [11, 12]:\n",
    "    cond = (df.时间.dt.month == month)\n",
    "    month_data = df.loc[cond]\n",
    "    # 准备好训练数据, \n",
    "    X_train = np.array([2017, 2016, 2015]).reshape(-1, 1)\n",
    "    \n",
    "    # 获取target,即金额\n",
    "    ys_ = []\n",
    "    for col in month_data.columns[1:]:\n",
    "        y_train = month_data[col].values\n",
    "#         print(y_train)\n",
    "        linear = LinearRegression()\n",
    "        linear.fit(X_train, y_train)\n",
    "        # 准备好预测数据\n",
    "        X_test = np.array([2018]).reshape(-1, 1)\n",
    "        y_ = linear.predict(X_test)\n",
    "#         print()\n",
    "        ys_.append(y_[0])\n",
    "    month_2018 = datetime.datetime(year=2018, month=month, day=1)\n",
    "    temp = DataFrame(data=[[month_2018] + ys_], columns=month_data.columns)\n",
    "#     print(temp)\n",
    "    df = temp.append(df)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>时间</th>\n",
       "      <th>灭鼠杀虫剂</th>\n",
       "      <th>电蚊香套装</th>\n",
       "      <th>盘香灭蟑香蚊香盘</th>\n",
       "      <th>蚊香加热器</th>\n",
       "      <th>蚊香液</th>\n",
       "      <th>蚊香片</th>\n",
       "      <th>防霉防蛀片</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-12-01</td>\n",
       "      <td>5.256763e+07</td>\n",
       "      <td>50204.53</td>\n",
       "      <td>9.285543e+05</td>\n",
       "      <td>8.684917e+04</td>\n",
       "      <td>3.081492e+06</td>\n",
       "      <td>4.268126e+05</td>\n",
       "      <td>3958717.58</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-11-01</td>\n",
       "      <td>7.175250e+07</td>\n",
       "      <td>38692.61</td>\n",
       "      <td>1.801319e+06</td>\n",
       "      <td>1.938744e+05</td>\n",
       "      <td>5.543204e+06</td>\n",
       "      <td>7.766270e+05</td>\n",
       "      <td>6678677.55</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-10-01</td>\n",
       "      <td>1.136548e+08</td>\n",
       "      <td>106531.29</td>\n",
       "      <td>4.171283e+06</td>\n",
       "      <td>3.156395e+05</td>\n",
       "      <td>7.814546e+06</td>\n",
       "      <td>1.032414e+06</td>\n",
       "      <td>8541153.59</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-09-01</td>\n",
       "      <td>1.440261e+08</td>\n",
       "      <td>105666.63</td>\n",
       "      <td>6.784500e+06</td>\n",
       "      <td>4.573664e+05</td>\n",
       "      <td>1.065497e+07</td>\n",
       "      <td>1.566652e+06</td>\n",
       "      <td>8825870.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-08-01</td>\n",
       "      <td>1.540426e+08</td>\n",
       "      <td>201467.03</td>\n",
       "      <td>1.070968e+07</td>\n",
       "      <td>7.465131e+05</td>\n",
       "      <td>1.783558e+07</td>\n",
       "      <td>2.617149e+06</td>\n",
       "      <td>6320153.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-07-01</td>\n",
       "      <td>1.480032e+08</td>\n",
       "      <td>438635.29</td>\n",
       "      <td>1.658918e+07</td>\n",
       "      <td>1.871757e+06</td>\n",
       "      <td>3.887792e+07</td>\n",
       "      <td>6.209040e+06</td>\n",
       "      <td>6302595.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-06-01</td>\n",
       "      <td>1.359438e+08</td>\n",
       "      <td>953749.78</td>\n",
       "      <td>2.352639e+07</td>\n",
       "      <td>3.641026e+06</td>\n",
       "      <td>7.649909e+07</td>\n",
       "      <td>1.248492e+07</td>\n",
       "      <td>7047206.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2018-05-01</td>\n",
       "      <td>1.241642e+08</td>\n",
       "      <td>1238967.37</td>\n",
       "      <td>2.811858e+07</td>\n",
       "      <td>5.032467e+06</td>\n",
       "      <td>1.050396e+08</td>\n",
       "      <td>1.530972e+07</td>\n",
       "      <td>7942340.44</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018-04-01</td>\n",
       "      <td>7.509661e+07</td>\n",
       "      <td>841051.93</td>\n",
       "      <td>1.642034e+07</td>\n",
       "      <td>3.130513e+06</td>\n",
       "      <td>6.254165e+07</td>\n",
       "      <td>7.954875e+06</td>\n",
       "      <td>7031364.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2018-03-01</td>\n",
       "      <td>5.918182e+07</td>\n",
       "      <td>475177.48</td>\n",
       "      <td>7.900095e+06</td>\n",
       "      <td>1.198333e+06</td>\n",
       "      <td>2.632447e+07</td>\n",
       "      <td>2.950648e+06</td>\n",
       "      <td>6051561.02</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2018-02-01</td>\n",
       "      <td>2.292138e+07</td>\n",
       "      <td>33232.95</td>\n",
       "      <td>5.459177e+05</td>\n",
       "      <td>7.571446e+04</td>\n",
       "      <td>2.235774e+06</td>\n",
       "      <td>2.189156e+05</td>\n",
       "      <td>1393948.47</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>3.653873e+07</td>\n",
       "      <td>54305.20</td>\n",
       "      <td>5.926632e+05</td>\n",
       "      <td>8.667045e+04</td>\n",
       "      <td>1.759451e+06</td>\n",
       "      <td>2.981461e+05</td>\n",
       "      <td>2607776.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2017-12-01</td>\n",
       "      <td>4.292283e+07</td>\n",
       "      <td>71600.17</td>\n",
       "      <td>7.969305e+05</td>\n",
       "      <td>6.914559e+04</td>\n",
       "      <td>2.213103e+06</td>\n",
       "      <td>3.141204e+05</td>\n",
       "      <td>3259747.23</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2017-11-01</td>\n",
       "      <td>5.838217e+07</td>\n",
       "      <td>94993.76</td>\n",
       "      <td>1.581530e+06</td>\n",
       "      <td>1.681418e+05</td>\n",
       "      <td>4.257594e+06</td>\n",
       "      <td>6.170949e+05</td>\n",
       "      <td>5447184.43</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2017-10-01</td>\n",
       "      <td>8.226882e+07</td>\n",
       "      <td>145925.31</td>\n",
       "      <td>2.824786e+06</td>\n",
       "      <td>1.665226e+05</td>\n",
       "      <td>4.290843e+06</td>\n",
       "      <td>7.665888e+05</td>\n",
       "      <td>6152868.25</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2017-09-01</td>\n",
       "      <td>1.010081e+08</td>\n",
       "      <td>242194.37</td>\n",
       "      <td>5.581352e+06</td>\n",
       "      <td>3.530425e+05</td>\n",
       "      <td>7.833349e+06</td>\n",
       "      <td>1.574780e+06</td>\n",
       "      <td>5792065.80</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2017-08-01</td>\n",
       "      <td>1.049504e+08</td>\n",
       "      <td>332922.02</td>\n",
       "      <td>7.229410e+06</td>\n",
       "      <td>5.440766e+05</td>\n",
       "      <td>1.376039e+07</td>\n",
       "      <td>2.323304e+06</td>\n",
       "      <td>5081714.64</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2017-07-01</td>\n",
       "      <td>1.116729e+08</td>\n",
       "      <td>913425.95</td>\n",
       "      <td>1.371805e+07</td>\n",
       "      <td>1.357779e+06</td>\n",
       "      <td>4.257757e+07</td>\n",
       "      <td>6.627300e+06</td>\n",
       "      <td>6691694.17</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2017-06-01</td>\n",
       "      <td>1.051463e+08</td>\n",
       "      <td>2045163.59</td>\n",
       "      <td>1.963593e+07</td>\n",
       "      <td>2.639778e+06</td>\n",
       "      <td>8.283230e+07</td>\n",
       "      <td>1.242242e+07</td>\n",
       "      <td>7155138.87</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2017-05-01</td>\n",
       "      <td>9.185035e+07</td>\n",
       "      <td>3606141.82</td>\n",
       "      <td>2.027552e+07</td>\n",
       "      <td>3.185962e+06</td>\n",
       "      <td>1.014605e+08</td>\n",
       "      <td>1.596195e+07</td>\n",
       "      <td>8145781.12</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2017-04-01</td>\n",
       "      <td>5.363586e+07</td>\n",
       "      <td>1285599.49</td>\n",
       "      <td>9.197868e+06</td>\n",
       "      <td>1.554864e+06</td>\n",
       "      <td>4.880687e+07</td>\n",
       "      <td>6.214964e+06</td>\n",
       "      <td>6682161.49</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2017-03-01</td>\n",
       "      <td>4.078967e+07</td>\n",
       "      <td>390486.57</td>\n",
       "      <td>3.397838e+06</td>\n",
       "      <td>3.172065e+05</td>\n",
       "      <td>1.488979e+07</td>\n",
       "      <td>1.319399e+06</td>\n",
       "      <td>3904656.82</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2017-02-01</td>\n",
       "      <td>3.467502e+07</td>\n",
       "      <td>209643.87</td>\n",
       "      <td>1.519446e+06</td>\n",
       "      <td>1.481581e+05</td>\n",
       "      <td>5.929509e+06</td>\n",
       "      <td>6.876975e+05</td>\n",
       "      <td>2584035.90</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>2.047156e+07</td>\n",
       "      <td>39434.76</td>\n",
       "      <td>5.967440e+05</td>\n",
       "      <td>4.816463e+04</td>\n",
       "      <td>1.213749e+06</td>\n",
       "      <td>2.389731e+05</td>\n",
       "      <td>1781773.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2016-12-01</td>\n",
       "      <td>3.546668e+07</td>\n",
       "      <td>84350.57</td>\n",
       "      <td>1.234900e+06</td>\n",
       "      <td>5.211896e+04</td>\n",
       "      <td>1.558634e+06</td>\n",
       "      <td>2.937372e+05</td>\n",
       "      <td>3504367.98</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2016-11-01</td>\n",
       "      <td>4.780625e+07</td>\n",
       "      <td>106291.23</td>\n",
       "      <td>1.473418e+06</td>\n",
       "      <td>8.283582e+04</td>\n",
       "      <td>2.758827e+06</td>\n",
       "      <td>5.129902e+05</td>\n",
       "      <td>4975519.21</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2016-10-01</td>\n",
       "      <td>6.339722e+07</td>\n",
       "      <td>179015.23</td>\n",
       "      <td>2.543814e+06</td>\n",
       "      <td>1.304841e+05</td>\n",
       "      <td>3.641803e+06</td>\n",
       "      <td>6.909120e+05</td>\n",
       "      <td>4600717.78</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2016-09-01</td>\n",
       "      <td>6.864724e+07</td>\n",
       "      <td>210456.69</td>\n",
       "      <td>3.092898e+06</td>\n",
       "      <td>1.687248e+05</td>\n",
       "      <td>4.632818e+06</td>\n",
       "      <td>9.305139e+05</td>\n",
       "      <td>4642681.07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2016-08-01</td>\n",
       "      <td>7.610885e+07</td>\n",
       "      <td>316467.14</td>\n",
       "      <td>4.389863e+06</td>\n",
       "      <td>2.725540e+05</td>\n",
       "      <td>8.956868e+06</td>\n",
       "      <td>1.581022e+06</td>\n",
       "      <td>4151326.68</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>7.832954e+07</td>\n",
       "      <td>932728.10</td>\n",
       "      <td>7.384969e+06</td>\n",
       "      <td>7.611593e+05</td>\n",
       "      <td>2.260036e+07</td>\n",
       "      <td>4.088321e+06</td>\n",
       "      <td>5412185.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2016-06-01</td>\n",
       "      <td>7.693264e+07</td>\n",
       "      <td>2184985.33</td>\n",
       "      <td>1.085946e+07</td>\n",
       "      <td>1.728789e+06</td>\n",
       "      <td>4.640197e+07</td>\n",
       "      <td>8.004563e+06</td>\n",
       "      <td>5694825.13</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2016-05-01</td>\n",
       "      <td>5.812696e+07</td>\n",
       "      <td>2059879.80</td>\n",
       "      <td>9.912802e+06</td>\n",
       "      <td>1.618362e+06</td>\n",
       "      <td>4.777690e+07</td>\n",
       "      <td>7.474422e+06</td>\n",
       "      <td>5469360.60</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2016-04-01</td>\n",
       "      <td>3.762602e+07</td>\n",
       "      <td>1034992.53</td>\n",
       "      <td>4.687913e+06</td>\n",
       "      <td>7.582068e+05</td>\n",
       "      <td>2.432917e+07</td>\n",
       "      <td>3.435257e+06</td>\n",
       "      <td>5253619.06</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2016-03-01</td>\n",
       "      <td>2.952610e+07</td>\n",
       "      <td>352013.31</td>\n",
       "      <td>1.204574e+06</td>\n",
       "      <td>2.461068e+05</td>\n",
       "      <td>6.656382e+06</td>\n",
       "      <td>7.467091e+05</td>\n",
       "      <td>3481194.46</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>1.500135e+07</td>\n",
       "      <td>96979.48</td>\n",
       "      <td>4.491994e+05</td>\n",
       "      <td>3.619385e+04</td>\n",
       "      <td>6.939075e+05</td>\n",
       "      <td>1.091081e+05</td>\n",
       "      <td>1274810.96</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2016-01-01</td>\n",
       "      <td>2.107822e+07</td>\n",
       "      <td>108412.71</td>\n",
       "      <td>6.190420e+05</td>\n",
       "      <td>4.967025e+04</td>\n",
       "      <td>4.828890e+05</td>\n",
       "      <td>1.132847e+05</td>\n",
       "      <td>1562393.95</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2015-12-01</td>\n",
       "      <td>2.472756e+07</td>\n",
       "      <td>110068.83</td>\n",
       "      <td>8.184796e+05</td>\n",
       "      <td>3.407691e+04</td>\n",
       "      <td>5.832845e+05</td>\n",
       "      <td>1.348905e+05</td>\n",
       "      <td>2333602.08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2015-11-01</td>\n",
       "      <td>3.303873e+07</td>\n",
       "      <td>185094.22</td>\n",
       "      <td>1.197791e+06</td>\n",
       "      <td>8.688991e+04</td>\n",
       "      <td>1.579796e+06</td>\n",
       "      <td>3.257444e+05</td>\n",
       "      <td>3364112.14</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           时间         灭鼠杀虫剂       电蚊香套装      盘香灭蟑香蚊香盘         蚊香加热器  \\\n",
       "0  2018-12-01  5.256763e+07    50204.53  9.285543e+05  8.684917e+04   \n",
       "0  2018-11-01  7.175250e+07    38692.61  1.801319e+06  1.938744e+05   \n",
       "0  2018-10-01  1.136548e+08   106531.29  4.171283e+06  3.156395e+05   \n",
       "1  2018-09-01  1.440261e+08   105666.63  6.784500e+06  4.573664e+05   \n",
       "2  2018-08-01  1.540426e+08   201467.03  1.070968e+07  7.465131e+05   \n",
       "3  2018-07-01  1.480032e+08   438635.29  1.658918e+07  1.871757e+06   \n",
       "4  2018-06-01  1.359438e+08   953749.78  2.352639e+07  3.641026e+06   \n",
       "5  2018-05-01  1.241642e+08  1238967.37  2.811858e+07  5.032467e+06   \n",
       "6  2018-04-01  7.509661e+07   841051.93  1.642034e+07  3.130513e+06   \n",
       "7  2018-03-01  5.918182e+07   475177.48  7.900095e+06  1.198333e+06   \n",
       "8  2018-02-01  2.292138e+07    33232.95  5.459177e+05  7.571446e+04   \n",
       "9  2018-01-01  3.653873e+07    54305.20  5.926632e+05  8.667045e+04   \n",
       "10 2017-12-01  4.292283e+07    71600.17  7.969305e+05  6.914559e+04   \n",
       "11 2017-11-01  5.838217e+07    94993.76  1.581530e+06  1.681418e+05   \n",
       "12 2017-10-01  8.226882e+07   145925.31  2.824786e+06  1.665226e+05   \n",
       "13 2017-09-01  1.010081e+08   242194.37  5.581352e+06  3.530425e+05   \n",
       "14 2017-08-01  1.049504e+08   332922.02  7.229410e+06  5.440766e+05   \n",
       "15 2017-07-01  1.116729e+08   913425.95  1.371805e+07  1.357779e+06   \n",
       "16 2017-06-01  1.051463e+08  2045163.59  1.963593e+07  2.639778e+06   \n",
       "17 2017-05-01  9.185035e+07  3606141.82  2.027552e+07  3.185962e+06   \n",
       "18 2017-04-01  5.363586e+07  1285599.49  9.197868e+06  1.554864e+06   \n",
       "19 2017-03-01  4.078967e+07   390486.57  3.397838e+06  3.172065e+05   \n",
       "20 2017-02-01  3.467502e+07   209643.87  1.519446e+06  1.481581e+05   \n",
       "21 2017-01-01  2.047156e+07    39434.76  5.967440e+05  4.816463e+04   \n",
       "22 2016-12-01  3.546668e+07    84350.57  1.234900e+06  5.211896e+04   \n",
       "23 2016-11-01  4.780625e+07   106291.23  1.473418e+06  8.283582e+04   \n",
       "24 2016-10-01  6.339722e+07   179015.23  2.543814e+06  1.304841e+05   \n",
       "25 2016-09-01  6.864724e+07   210456.69  3.092898e+06  1.687248e+05   \n",
       "26 2016-08-01  7.610885e+07   316467.14  4.389863e+06  2.725540e+05   \n",
       "27 2016-07-01  7.832954e+07   932728.10  7.384969e+06  7.611593e+05   \n",
       "28 2016-06-01  7.693264e+07  2184985.33  1.085946e+07  1.728789e+06   \n",
       "29 2016-05-01  5.812696e+07  2059879.80  9.912802e+06  1.618362e+06   \n",
       "30 2016-04-01  3.762602e+07  1034992.53  4.687913e+06  7.582068e+05   \n",
       "31 2016-03-01  2.952610e+07   352013.31  1.204574e+06  2.461068e+05   \n",
       "32 2016-02-01  1.500135e+07    96979.48  4.491994e+05  3.619385e+04   \n",
       "33 2016-01-01  2.107822e+07   108412.71  6.190420e+05  4.967025e+04   \n",
       "34 2015-12-01  2.472756e+07   110068.83  8.184796e+05  3.407691e+04   \n",
       "35 2015-11-01  3.303873e+07   185094.22  1.197791e+06  8.688991e+04   \n",
       "\n",
       "             蚊香液           蚊香片       防霉防蛀片  \n",
       "0   3.081492e+06  4.268126e+05  3958717.58  \n",
       "0   5.543204e+06  7.766270e+05  6678677.55  \n",
       "0   7.814546e+06  1.032414e+06  8541153.59  \n",
       "1   1.065497e+07  1.566652e+06  8825870.43  \n",
       "2   1.783558e+07  2.617149e+06  6320153.44  \n",
       "3   3.887792e+07  6.209040e+06  6302595.06  \n",
       "4   7.649909e+07  1.248492e+07  7047206.98  \n",
       "5   1.050396e+08  1.530972e+07  7942340.44  \n",
       "6   6.254165e+07  7.954875e+06  7031364.60  \n",
       "7   2.632447e+07  2.950648e+06  6051561.02  \n",
       "8   2.235774e+06  2.189156e+05  1393948.47  \n",
       "9   1.759451e+06  2.981461e+05  2607776.07  \n",
       "10  2.213103e+06  3.141204e+05  3259747.23  \n",
       "11  4.257594e+06  6.170949e+05  5447184.43  \n",
       "12  4.290843e+06  7.665888e+05  6152868.25  \n",
       "13  7.833349e+06  1.574780e+06  5792065.80  \n",
       "14  1.376039e+07  2.323304e+06  5081714.64  \n",
       "15  4.257757e+07  6.627300e+06  6691694.17  \n",
       "16  8.283230e+07  1.242242e+07  7155138.87  \n",
       "17  1.014605e+08  1.596195e+07  8145781.12  \n",
       "18  4.880687e+07  6.214964e+06  6682161.49  \n",
       "19  1.488979e+07  1.319399e+06  3904656.82  \n",
       "20  5.929509e+06  6.876975e+05  2584035.90  \n",
       "21  1.213749e+06  2.389731e+05  1781773.46  \n",
       "22  1.558634e+06  2.937372e+05  3504367.98  \n",
       "23  2.758827e+06  5.129902e+05  4975519.21  \n",
       "24  3.641803e+06  6.909120e+05  4600717.78  \n",
       "25  4.632818e+06  9.305139e+05  4642681.07  \n",
       "26  8.956868e+06  1.581022e+06  4151326.68  \n",
       "27  2.260036e+07  4.088321e+06  5412185.06  \n",
       "28  4.640197e+07  8.004563e+06  5694825.13  \n",
       "29  4.777690e+07  7.474422e+06  5469360.60  \n",
       "30  2.432917e+07  3.435257e+06  5253619.06  \n",
       "31  6.656382e+06  7.467091e+05  3481194.46  \n",
       "32  6.939075e+05  1.091081e+05  1274810.96  \n",
       "33  4.828890e+05  1.132847e+05  1562393.95  \n",
       "34  5.832845e+05  1.348905e+05  2333602.08  \n",
       "35  1.579796e+06  3.257444e+05  3364112.14  "
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Looking in indexes: https://pypi.douban.com/simple\n",
      "Requirement already satisfied: mysqlclient in d:\\2005\\.venv\\lib\\site-packages (2.0.3)\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "WARNING: You are using pip version 20.1.1; however, version 21.0.1 is available.\n",
      "You should consider upgrading via the 'D:\\2005\\.venv\\Scripts\\python.exe -m pip install --upgrade pip' command.\n"
     ]
    }
   ],
   "source": [
    "!pip install mysqlclient -i https://pypi.douban.com/simple"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 20,
   "metadata": {},
   "outputs": [],
   "source": [
    "engine = create_engine('mysql+mysqldb://zhangsan:Changeme_123@47.107.190.1/bayer?charset=utf8mb4')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 23,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 重新分配索引\n",
    "df.reset_index(drop=True, inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 删掉15年的数据\n",
    "df.drop(index=[36, 37], inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.to_sql('parasite', engine)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "0     1.222005e+08\n",
       "1     1.735698e+08\n",
       "2     2.712727e+08\n",
       "3     3.448422e+08\n",
       "4     3.849462e+08\n",
       "5     4.365847e+08\n",
       "6     5.201924e+08\n",
       "7     5.736918e+08\n",
       "8     3.460328e+08\n",
       "9     2.081642e+08\n",
       "10    5.484976e+07\n",
       "11    8.387549e+07\n",
       "12    9.929496e+07\n",
       "13    1.410974e+08\n",
       "14    1.932327e+08\n",
       "15    2.447697e+08\n",
       "16    2.684445e+08\n",
       "17    3.671174e+08\n",
       "18    4.637541e+08\n",
       "19    4.889724e+08\n",
       "20    2.547564e+08\n",
       "21    1.300181e+08\n",
       "22    9.150703e+07\n",
       "23    4.878081e+07\n",
       "24    8.438958e+07\n",
       "25    1.154323e+08\n",
       "26    1.503679e+08\n",
       "27    1.646507e+08\n",
       "28    1.915539e+08\n",
       "29    2.390185e+08\n",
       "30    3.036145e+08\n",
       "31    2.648774e+08\n",
       "32    1.542504e+08\n",
       "33    8.442615e+07\n",
       "34    3.532310e+07\n",
       "35    4.802783e+07\n",
       "dtype: float64"
      ]
     },
     "execution_count": 28,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 26,
   "metadata": {},
   "outputs": [],
   "source": [
    "df['总金额'] = df.sum(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [],
   "source": [
    "df.set_index(keys='时间', inplace=True)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/plain": [
       "时间\n",
       "2018-12-01    1.222005e+08\n",
       "2018-11-01    1.735698e+08\n",
       "2018-10-01    2.712727e+08\n",
       "2018-09-01    3.448422e+08\n",
       "2018-08-01    3.849462e+08\n",
       "2018-07-01    4.365847e+08\n",
       "2018-06-01    5.201924e+08\n",
       "2018-05-01    5.736918e+08\n",
       "2018-04-01    3.460328e+08\n",
       "2018-03-01    2.081642e+08\n",
       "2018-02-01    5.484976e+07\n",
       "2018-01-01    8.387549e+07\n",
       "2017-12-01    9.929496e+07\n",
       "2017-11-01    1.410974e+08\n",
       "2017-10-01    1.932327e+08\n",
       "2017-09-01    2.447697e+08\n",
       "2017-08-01    2.684445e+08\n",
       "2017-07-01    3.671174e+08\n",
       "2017-06-01    4.637541e+08\n",
       "2017-05-01    4.889724e+08\n",
       "2017-04-01    2.547564e+08\n",
       "2017-03-01    1.300181e+08\n",
       "2017-02-01    9.150703e+07\n",
       "2017-01-01    4.878081e+07\n",
       "2016-12-01    8.438958e+07\n",
       "2016-11-01    1.154323e+08\n",
       "2016-10-01    1.503679e+08\n",
       "2016-09-01    1.646507e+08\n",
       "2016-08-01    1.915539e+08\n",
       "2016-07-01    2.390185e+08\n",
       "2016-06-01    3.036145e+08\n",
       "2016-05-01    2.648774e+08\n",
       "2016-04-01    1.542504e+08\n",
       "2016-03-01    8.442615e+07\n",
       "2016-02-01    3.532310e+07\n",
       "2016-01-01    4.802783e+07\n",
       "dtype: float64"
      ]
     },
     "execution_count": 31,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.sum(axis=1)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 32,
   "metadata": {
    "collapsed": true
   },
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>灭鼠杀虫剂</th>\n",
       "      <th>电蚊香套装</th>\n",
       "      <th>盘香灭蟑香蚊香盘</th>\n",
       "      <th>蚊香加热器</th>\n",
       "      <th>蚊香液</th>\n",
       "      <th>蚊香片</th>\n",
       "      <th>防霉防蛀片</th>\n",
       "      <th>总金额</th>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>时间</th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "      <th></th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>2018-12-01</th>\n",
       "      <td>5.256763e+07</td>\n",
       "      <td>50204.53</td>\n",
       "      <td>9.285543e+05</td>\n",
       "      <td>8.684917e+04</td>\n",
       "      <td>3.081492e+06</td>\n",
       "      <td>4.268126e+05</td>\n",
       "      <td>3958717.58</td>\n",
       "      <td>6.110026e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-11-01</th>\n",
       "      <td>7.175250e+07</td>\n",
       "      <td>38692.61</td>\n",
       "      <td>1.801319e+06</td>\n",
       "      <td>1.938744e+05</td>\n",
       "      <td>5.543204e+06</td>\n",
       "      <td>7.766270e+05</td>\n",
       "      <td>6678677.55</td>\n",
       "      <td>8.678489e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-10-01</th>\n",
       "      <td>1.136548e+08</td>\n",
       "      <td>106531.29</td>\n",
       "      <td>4.171283e+06</td>\n",
       "      <td>3.156395e+05</td>\n",
       "      <td>7.814546e+06</td>\n",
       "      <td>1.032414e+06</td>\n",
       "      <td>8541153.59</td>\n",
       "      <td>1.356363e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-09-01</th>\n",
       "      <td>1.440261e+08</td>\n",
       "      <td>105666.63</td>\n",
       "      <td>6.784500e+06</td>\n",
       "      <td>4.573664e+05</td>\n",
       "      <td>1.065497e+07</td>\n",
       "      <td>1.566652e+06</td>\n",
       "      <td>8825870.43</td>\n",
       "      <td>1.724211e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-08-01</th>\n",
       "      <td>1.540426e+08</td>\n",
       "      <td>201467.03</td>\n",
       "      <td>1.070968e+07</td>\n",
       "      <td>7.465131e+05</td>\n",
       "      <td>1.783558e+07</td>\n",
       "      <td>2.617149e+06</td>\n",
       "      <td>6320153.44</td>\n",
       "      <td>1.924731e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-07-01</th>\n",
       "      <td>1.480032e+08</td>\n",
       "      <td>438635.29</td>\n",
       "      <td>1.658918e+07</td>\n",
       "      <td>1.871757e+06</td>\n",
       "      <td>3.887792e+07</td>\n",
       "      <td>6.209040e+06</td>\n",
       "      <td>6302595.06</td>\n",
       "      <td>2.182924e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-06-01</th>\n",
       "      <td>1.359438e+08</td>\n",
       "      <td>953749.78</td>\n",
       "      <td>2.352639e+07</td>\n",
       "      <td>3.641026e+06</td>\n",
       "      <td>7.649909e+07</td>\n",
       "      <td>1.248492e+07</td>\n",
       "      <td>7047206.98</td>\n",
       "      <td>2.600962e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-05-01</th>\n",
       "      <td>1.241642e+08</td>\n",
       "      <td>1238967.37</td>\n",
       "      <td>2.811858e+07</td>\n",
       "      <td>5.032467e+06</td>\n",
       "      <td>1.050396e+08</td>\n",
       "      <td>1.530972e+07</td>\n",
       "      <td>7942340.44</td>\n",
       "      <td>2.868459e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-04-01</th>\n",
       "      <td>7.509661e+07</td>\n",
       "      <td>841051.93</td>\n",
       "      <td>1.642034e+07</td>\n",
       "      <td>3.130513e+06</td>\n",
       "      <td>6.254165e+07</td>\n",
       "      <td>7.954875e+06</td>\n",
       "      <td>7031364.60</td>\n",
       "      <td>1.730164e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-03-01</th>\n",
       "      <td>5.918182e+07</td>\n",
       "      <td>475177.48</td>\n",
       "      <td>7.900095e+06</td>\n",
       "      <td>1.198333e+06</td>\n",
       "      <td>2.632447e+07</td>\n",
       "      <td>2.950648e+06</td>\n",
       "      <td>6051561.02</td>\n",
       "      <td>1.040821e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-02-01</th>\n",
       "      <td>2.292138e+07</td>\n",
       "      <td>33232.95</td>\n",
       "      <td>5.459177e+05</td>\n",
       "      <td>7.571446e+04</td>\n",
       "      <td>2.235774e+06</td>\n",
       "      <td>2.189156e+05</td>\n",
       "      <td>1393948.47</td>\n",
       "      <td>2.742488e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2018-01-01</th>\n",
       "      <td>3.653873e+07</td>\n",
       "      <td>54305.20</td>\n",
       "      <td>5.926632e+05</td>\n",
       "      <td>8.667045e+04</td>\n",
       "      <td>1.759451e+06</td>\n",
       "      <td>2.981461e+05</td>\n",
       "      <td>2607776.07</td>\n",
       "      <td>4.193774e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-12-01</th>\n",
       "      <td>4.292283e+07</td>\n",
       "      <td>71600.17</td>\n",
       "      <td>7.969305e+05</td>\n",
       "      <td>6.914559e+04</td>\n",
       "      <td>2.213103e+06</td>\n",
       "      <td>3.141204e+05</td>\n",
       "      <td>3259747.23</td>\n",
       "      <td>4.964748e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-11-01</th>\n",
       "      <td>5.838217e+07</td>\n",
       "      <td>94993.76</td>\n",
       "      <td>1.581530e+06</td>\n",
       "      <td>1.681418e+05</td>\n",
       "      <td>4.257594e+06</td>\n",
       "      <td>6.170949e+05</td>\n",
       "      <td>5447184.43</td>\n",
       "      <td>7.054871e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-10-01</th>\n",
       "      <td>8.226882e+07</td>\n",
       "      <td>145925.31</td>\n",
       "      <td>2.824786e+06</td>\n",
       "      <td>1.665226e+05</td>\n",
       "      <td>4.290843e+06</td>\n",
       "      <td>7.665888e+05</td>\n",
       "      <td>6152868.25</td>\n",
       "      <td>9.661636e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-09-01</th>\n",
       "      <td>1.010081e+08</td>\n",
       "      <td>242194.37</td>\n",
       "      <td>5.581352e+06</td>\n",
       "      <td>3.530425e+05</td>\n",
       "      <td>7.833349e+06</td>\n",
       "      <td>1.574780e+06</td>\n",
       "      <td>5792065.80</td>\n",
       "      <td>1.223849e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-08-01</th>\n",
       "      <td>1.049504e+08</td>\n",
       "      <td>332922.02</td>\n",
       "      <td>7.229410e+06</td>\n",
       "      <td>5.440766e+05</td>\n",
       "      <td>1.376039e+07</td>\n",
       "      <td>2.323304e+06</td>\n",
       "      <td>5081714.64</td>\n",
       "      <td>1.342222e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-07-01</th>\n",
       "      <td>1.116729e+08</td>\n",
       "      <td>913425.95</td>\n",
       "      <td>1.371805e+07</td>\n",
       "      <td>1.357779e+06</td>\n",
       "      <td>4.257757e+07</td>\n",
       "      <td>6.627300e+06</td>\n",
       "      <td>6691694.17</td>\n",
       "      <td>1.835587e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-06-01</th>\n",
       "      <td>1.051463e+08</td>\n",
       "      <td>2045163.59</td>\n",
       "      <td>1.963593e+07</td>\n",
       "      <td>2.639778e+06</td>\n",
       "      <td>8.283230e+07</td>\n",
       "      <td>1.242242e+07</td>\n",
       "      <td>7155138.87</td>\n",
       "      <td>2.318770e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-05-01</th>\n",
       "      <td>9.185035e+07</td>\n",
       "      <td>3606141.82</td>\n",
       "      <td>2.027552e+07</td>\n",
       "      <td>3.185962e+06</td>\n",
       "      <td>1.014605e+08</td>\n",
       "      <td>1.596195e+07</td>\n",
       "      <td>8145781.12</td>\n",
       "      <td>2.444862e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-04-01</th>\n",
       "      <td>5.363586e+07</td>\n",
       "      <td>1285599.49</td>\n",
       "      <td>9.197868e+06</td>\n",
       "      <td>1.554864e+06</td>\n",
       "      <td>4.880687e+07</td>\n",
       "      <td>6.214964e+06</td>\n",
       "      <td>6682161.49</td>\n",
       "      <td>1.273782e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-03-01</th>\n",
       "      <td>4.078967e+07</td>\n",
       "      <td>390486.57</td>\n",
       "      <td>3.397838e+06</td>\n",
       "      <td>3.172065e+05</td>\n",
       "      <td>1.488979e+07</td>\n",
       "      <td>1.319399e+06</td>\n",
       "      <td>3904656.82</td>\n",
       "      <td>6.500904e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-02-01</th>\n",
       "      <td>3.467502e+07</td>\n",
       "      <td>209643.87</td>\n",
       "      <td>1.519446e+06</td>\n",
       "      <td>1.481581e+05</td>\n",
       "      <td>5.929509e+06</td>\n",
       "      <td>6.876975e+05</td>\n",
       "      <td>2584035.90</td>\n",
       "      <td>4.575351e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2017-01-01</th>\n",
       "      <td>2.047156e+07</td>\n",
       "      <td>39434.76</td>\n",
       "      <td>5.967440e+05</td>\n",
       "      <td>4.816463e+04</td>\n",
       "      <td>1.213749e+06</td>\n",
       "      <td>2.389731e+05</td>\n",
       "      <td>1781773.46</td>\n",
       "      <td>2.439040e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-12-01</th>\n",
       "      <td>3.546668e+07</td>\n",
       "      <td>84350.57</td>\n",
       "      <td>1.234900e+06</td>\n",
       "      <td>5.211896e+04</td>\n",
       "      <td>1.558634e+06</td>\n",
       "      <td>2.937372e+05</td>\n",
       "      <td>3504367.98</td>\n",
       "      <td>4.219479e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-11-01</th>\n",
       "      <td>4.780625e+07</td>\n",
       "      <td>106291.23</td>\n",
       "      <td>1.473418e+06</td>\n",
       "      <td>8.283582e+04</td>\n",
       "      <td>2.758827e+06</td>\n",
       "      <td>5.129902e+05</td>\n",
       "      <td>4975519.21</td>\n",
       "      <td>5.771613e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-10-01</th>\n",
       "      <td>6.339722e+07</td>\n",
       "      <td>179015.23</td>\n",
       "      <td>2.543814e+06</td>\n",
       "      <td>1.304841e+05</td>\n",
       "      <td>3.641803e+06</td>\n",
       "      <td>6.909120e+05</td>\n",
       "      <td>4600717.78</td>\n",
       "      <td>7.518397e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-09-01</th>\n",
       "      <td>6.864724e+07</td>\n",
       "      <td>210456.69</td>\n",
       "      <td>3.092898e+06</td>\n",
       "      <td>1.687248e+05</td>\n",
       "      <td>4.632818e+06</td>\n",
       "      <td>9.305139e+05</td>\n",
       "      <td>4642681.07</td>\n",
       "      <td>8.232534e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-08-01</th>\n",
       "      <td>7.610885e+07</td>\n",
       "      <td>316467.14</td>\n",
       "      <td>4.389863e+06</td>\n",
       "      <td>2.725540e+05</td>\n",
       "      <td>8.956868e+06</td>\n",
       "      <td>1.581022e+06</td>\n",
       "      <td>4151326.68</td>\n",
       "      <td>9.577695e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-07-01</th>\n",
       "      <td>7.832954e+07</td>\n",
       "      <td>932728.10</td>\n",
       "      <td>7.384969e+06</td>\n",
       "      <td>7.611593e+05</td>\n",
       "      <td>2.260036e+07</td>\n",
       "      <td>4.088321e+06</td>\n",
       "      <td>5412185.06</td>\n",
       "      <td>1.195093e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-06-01</th>\n",
       "      <td>7.693264e+07</td>\n",
       "      <td>2184985.33</td>\n",
       "      <td>1.085946e+07</td>\n",
       "      <td>1.728789e+06</td>\n",
       "      <td>4.640197e+07</td>\n",
       "      <td>8.004563e+06</td>\n",
       "      <td>5694825.13</td>\n",
       "      <td>1.518072e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-05-01</th>\n",
       "      <td>5.812696e+07</td>\n",
       "      <td>2059879.80</td>\n",
       "      <td>9.912802e+06</td>\n",
       "      <td>1.618362e+06</td>\n",
       "      <td>4.777690e+07</td>\n",
       "      <td>7.474422e+06</td>\n",
       "      <td>5469360.60</td>\n",
       "      <td>1.324387e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-04-01</th>\n",
       "      <td>3.762602e+07</td>\n",
       "      <td>1034992.53</td>\n",
       "      <td>4.687913e+06</td>\n",
       "      <td>7.582068e+05</td>\n",
       "      <td>2.432917e+07</td>\n",
       "      <td>3.435257e+06</td>\n",
       "      <td>5253619.06</td>\n",
       "      <td>7.712518e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-03-01</th>\n",
       "      <td>2.952610e+07</td>\n",
       "      <td>352013.31</td>\n",
       "      <td>1.204574e+06</td>\n",
       "      <td>2.461068e+05</td>\n",
       "      <td>6.656382e+06</td>\n",
       "      <td>7.467091e+05</td>\n",
       "      <td>3481194.46</td>\n",
       "      <td>4.221308e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-02-01</th>\n",
       "      <td>1.500135e+07</td>\n",
       "      <td>96979.48</td>\n",
       "      <td>4.491994e+05</td>\n",
       "      <td>3.619385e+04</td>\n",
       "      <td>6.939075e+05</td>\n",
       "      <td>1.091081e+05</td>\n",
       "      <td>1274810.96</td>\n",
       "      <td>1.766155e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2016-01-01</th>\n",
       "      <td>2.107822e+07</td>\n",
       "      <td>108412.71</td>\n",
       "      <td>6.190420e+05</td>\n",
       "      <td>4.967025e+04</td>\n",
       "      <td>4.828890e+05</td>\n",
       "      <td>1.132847e+05</td>\n",
       "      <td>1562393.95</td>\n",
       "      <td>2.401391e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "                   灭鼠杀虫剂       电蚊香套装      盘香灭蟑香蚊香盘         蚊香加热器  \\\n",
       "时间                                                                 \n",
       "2018-12-01  5.256763e+07    50204.53  9.285543e+05  8.684917e+04   \n",
       "2018-11-01  7.175250e+07    38692.61  1.801319e+06  1.938744e+05   \n",
       "2018-10-01  1.136548e+08   106531.29  4.171283e+06  3.156395e+05   \n",
       "2018-09-01  1.440261e+08   105666.63  6.784500e+06  4.573664e+05   \n",
       "2018-08-01  1.540426e+08   201467.03  1.070968e+07  7.465131e+05   \n",
       "2018-07-01  1.480032e+08   438635.29  1.658918e+07  1.871757e+06   \n",
       "2018-06-01  1.359438e+08   953749.78  2.352639e+07  3.641026e+06   \n",
       "2018-05-01  1.241642e+08  1238967.37  2.811858e+07  5.032467e+06   \n",
       "2018-04-01  7.509661e+07   841051.93  1.642034e+07  3.130513e+06   \n",
       "2018-03-01  5.918182e+07   475177.48  7.900095e+06  1.198333e+06   \n",
       "2018-02-01  2.292138e+07    33232.95  5.459177e+05  7.571446e+04   \n",
       "2018-01-01  3.653873e+07    54305.20  5.926632e+05  8.667045e+04   \n",
       "2017-12-01  4.292283e+07    71600.17  7.969305e+05  6.914559e+04   \n",
       "2017-11-01  5.838217e+07    94993.76  1.581530e+06  1.681418e+05   \n",
       "2017-10-01  8.226882e+07   145925.31  2.824786e+06  1.665226e+05   \n",
       "2017-09-01  1.010081e+08   242194.37  5.581352e+06  3.530425e+05   \n",
       "2017-08-01  1.049504e+08   332922.02  7.229410e+06  5.440766e+05   \n",
       "2017-07-01  1.116729e+08   913425.95  1.371805e+07  1.357779e+06   \n",
       "2017-06-01  1.051463e+08  2045163.59  1.963593e+07  2.639778e+06   \n",
       "2017-05-01  9.185035e+07  3606141.82  2.027552e+07  3.185962e+06   \n",
       "2017-04-01  5.363586e+07  1285599.49  9.197868e+06  1.554864e+06   \n",
       "2017-03-01  4.078967e+07   390486.57  3.397838e+06  3.172065e+05   \n",
       "2017-02-01  3.467502e+07   209643.87  1.519446e+06  1.481581e+05   \n",
       "2017-01-01  2.047156e+07    39434.76  5.967440e+05  4.816463e+04   \n",
       "2016-12-01  3.546668e+07    84350.57  1.234900e+06  5.211896e+04   \n",
       "2016-11-01  4.780625e+07   106291.23  1.473418e+06  8.283582e+04   \n",
       "2016-10-01  6.339722e+07   179015.23  2.543814e+06  1.304841e+05   \n",
       "2016-09-01  6.864724e+07   210456.69  3.092898e+06  1.687248e+05   \n",
       "2016-08-01  7.610885e+07   316467.14  4.389863e+06  2.725540e+05   \n",
       "2016-07-01  7.832954e+07   932728.10  7.384969e+06  7.611593e+05   \n",
       "2016-06-01  7.693264e+07  2184985.33  1.085946e+07  1.728789e+06   \n",
       "2016-05-01  5.812696e+07  2059879.80  9.912802e+06  1.618362e+06   \n",
       "2016-04-01  3.762602e+07  1034992.53  4.687913e+06  7.582068e+05   \n",
       "2016-03-01  2.952610e+07   352013.31  1.204574e+06  2.461068e+05   \n",
       "2016-02-01  1.500135e+07    96979.48  4.491994e+05  3.619385e+04   \n",
       "2016-01-01  2.107822e+07   108412.71  6.190420e+05  4.967025e+04   \n",
       "\n",
       "                     蚊香液           蚊香片       防霉防蛀片           总金额  \n",
       "时间                                                                \n",
       "2018-12-01  3.081492e+06  4.268126e+05  3958717.58  6.110026e+07  \n",
       "2018-11-01  5.543204e+06  7.766270e+05  6678677.55  8.678489e+07  \n",
       "2018-10-01  7.814546e+06  1.032414e+06  8541153.59  1.356363e+08  \n",
       "2018-09-01  1.065497e+07  1.566652e+06  8825870.43  1.724211e+08  \n",
       "2018-08-01  1.783558e+07  2.617149e+06  6320153.44  1.924731e+08  \n",
       "2018-07-01  3.887792e+07  6.209040e+06  6302595.06  2.182924e+08  \n",
       "2018-06-01  7.649909e+07  1.248492e+07  7047206.98  2.600962e+08  \n",
       "2018-05-01  1.050396e+08  1.530972e+07  7942340.44  2.868459e+08  \n",
       "2018-04-01  6.254165e+07  7.954875e+06  7031364.60  1.730164e+08  \n",
       "2018-03-01  2.632447e+07  2.950648e+06  6051561.02  1.040821e+08  \n",
       "2018-02-01  2.235774e+06  2.189156e+05  1393948.47  2.742488e+07  \n",
       "2018-01-01  1.759451e+06  2.981461e+05  2607776.07  4.193774e+07  \n",
       "2017-12-01  2.213103e+06  3.141204e+05  3259747.23  4.964748e+07  \n",
       "2017-11-01  4.257594e+06  6.170949e+05  5447184.43  7.054871e+07  \n",
       "2017-10-01  4.290843e+06  7.665888e+05  6152868.25  9.661636e+07  \n",
       "2017-09-01  7.833349e+06  1.574780e+06  5792065.80  1.223849e+08  \n",
       "2017-08-01  1.376039e+07  2.323304e+06  5081714.64  1.342222e+08  \n",
       "2017-07-01  4.257757e+07  6.627300e+06  6691694.17  1.835587e+08  \n",
       "2017-06-01  8.283230e+07  1.242242e+07  7155138.87  2.318770e+08  \n",
       "2017-05-01  1.014605e+08  1.596195e+07  8145781.12  2.444862e+08  \n",
       "2017-04-01  4.880687e+07  6.214964e+06  6682161.49  1.273782e+08  \n",
       "2017-03-01  1.488979e+07  1.319399e+06  3904656.82  6.500904e+07  \n",
       "2017-02-01  5.929509e+06  6.876975e+05  2584035.90  4.575351e+07  \n",
       "2017-01-01  1.213749e+06  2.389731e+05  1781773.46  2.439040e+07  \n",
       "2016-12-01  1.558634e+06  2.937372e+05  3504367.98  4.219479e+07  \n",
       "2016-11-01  2.758827e+06  5.129902e+05  4975519.21  5.771613e+07  \n",
       "2016-10-01  3.641803e+06  6.909120e+05  4600717.78  7.518397e+07  \n",
       "2016-09-01  4.632818e+06  9.305139e+05  4642681.07  8.232534e+07  \n",
       "2016-08-01  8.956868e+06  1.581022e+06  4151326.68  9.577695e+07  \n",
       "2016-07-01  2.260036e+07  4.088321e+06  5412185.06  1.195093e+08  \n",
       "2016-06-01  4.640197e+07  8.004563e+06  5694825.13  1.518072e+08  \n",
       "2016-05-01  4.777690e+07  7.474422e+06  5469360.60  1.324387e+08  \n",
       "2016-04-01  2.432917e+07  3.435257e+06  5253619.06  7.712518e+07  \n",
       "2016-03-01  6.656382e+06  7.467091e+05  3481194.46  4.221308e+07  \n",
       "2016-02-01  6.939075e+05  1.091081e+05  1274810.96  1.766155e+07  \n",
       "2016-01-01  4.828890e+05  1.132847e+05  1562393.95  2.401391e+07  "
      ]
     },
     "execution_count": 32,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 33,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/html": [
       "<div>\n",
       "<style scoped>\n",
       "    .dataframe tbody tr th:only-of-type {\n",
       "        vertical-align: middle;\n",
       "    }\n",
       "\n",
       "    .dataframe tbody tr th {\n",
       "        vertical-align: top;\n",
       "    }\n",
       "\n",
       "    .dataframe thead th {\n",
       "        text-align: right;\n",
       "    }\n",
       "</style>\n",
       "<table border=\"1\" class=\"dataframe\">\n",
       "  <thead>\n",
       "    <tr style=\"text-align: right;\">\n",
       "      <th></th>\n",
       "      <th>时间</th>\n",
       "      <th>灭鼠杀虫剂</th>\n",
       "      <th>电蚊香套装</th>\n",
       "      <th>盘香灭蟑香蚊香盘</th>\n",
       "      <th>蚊香加热器</th>\n",
       "      <th>蚊香液</th>\n",
       "      <th>蚊香片</th>\n",
       "      <th>防霉防蛀片</th>\n",
       "      <th>总金额</th>\n",
       "    </tr>\n",
       "  </thead>\n",
       "  <tbody>\n",
       "    <tr>\n",
       "      <th>0</th>\n",
       "      <td>2018-12-01</td>\n",
       "      <td>5.256763e+07</td>\n",
       "      <td>50204.53</td>\n",
       "      <td>9.285543e+05</td>\n",
       "      <td>8.684917e+04</td>\n",
       "      <td>3.081492e+06</td>\n",
       "      <td>4.268126e+05</td>\n",
       "      <td>3958717.58</td>\n",
       "      <td>6.110026e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>1</th>\n",
       "      <td>2018-11-01</td>\n",
       "      <td>7.175250e+07</td>\n",
       "      <td>38692.61</td>\n",
       "      <td>1.801319e+06</td>\n",
       "      <td>1.938744e+05</td>\n",
       "      <td>5.543204e+06</td>\n",
       "      <td>7.766270e+05</td>\n",
       "      <td>6678677.55</td>\n",
       "      <td>8.678489e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>2</th>\n",
       "      <td>2018-10-01</td>\n",
       "      <td>1.136548e+08</td>\n",
       "      <td>106531.29</td>\n",
       "      <td>4.171283e+06</td>\n",
       "      <td>3.156395e+05</td>\n",
       "      <td>7.814546e+06</td>\n",
       "      <td>1.032414e+06</td>\n",
       "      <td>8541153.59</td>\n",
       "      <td>1.356363e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>3</th>\n",
       "      <td>2018-09-01</td>\n",
       "      <td>1.440261e+08</td>\n",
       "      <td>105666.63</td>\n",
       "      <td>6.784500e+06</td>\n",
       "      <td>4.573664e+05</td>\n",
       "      <td>1.065497e+07</td>\n",
       "      <td>1.566652e+06</td>\n",
       "      <td>8825870.43</td>\n",
       "      <td>1.724211e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>4</th>\n",
       "      <td>2018-08-01</td>\n",
       "      <td>1.540426e+08</td>\n",
       "      <td>201467.03</td>\n",
       "      <td>1.070968e+07</td>\n",
       "      <td>7.465131e+05</td>\n",
       "      <td>1.783558e+07</td>\n",
       "      <td>2.617149e+06</td>\n",
       "      <td>6320153.44</td>\n",
       "      <td>1.924731e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>5</th>\n",
       "      <td>2018-07-01</td>\n",
       "      <td>1.480032e+08</td>\n",
       "      <td>438635.29</td>\n",
       "      <td>1.658918e+07</td>\n",
       "      <td>1.871757e+06</td>\n",
       "      <td>3.887792e+07</td>\n",
       "      <td>6.209040e+06</td>\n",
       "      <td>6302595.06</td>\n",
       "      <td>2.182924e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>6</th>\n",
       "      <td>2018-06-01</td>\n",
       "      <td>1.359438e+08</td>\n",
       "      <td>953749.78</td>\n",
       "      <td>2.352639e+07</td>\n",
       "      <td>3.641026e+06</td>\n",
       "      <td>7.649909e+07</td>\n",
       "      <td>1.248492e+07</td>\n",
       "      <td>7047206.98</td>\n",
       "      <td>2.600962e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>7</th>\n",
       "      <td>2018-05-01</td>\n",
       "      <td>1.241642e+08</td>\n",
       "      <td>1238967.37</td>\n",
       "      <td>2.811858e+07</td>\n",
       "      <td>5.032467e+06</td>\n",
       "      <td>1.050396e+08</td>\n",
       "      <td>1.530972e+07</td>\n",
       "      <td>7942340.44</td>\n",
       "      <td>2.868459e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>8</th>\n",
       "      <td>2018-04-01</td>\n",
       "      <td>7.509661e+07</td>\n",
       "      <td>841051.93</td>\n",
       "      <td>1.642034e+07</td>\n",
       "      <td>3.130513e+06</td>\n",
       "      <td>6.254165e+07</td>\n",
       "      <td>7.954875e+06</td>\n",
       "      <td>7031364.60</td>\n",
       "      <td>1.730164e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>9</th>\n",
       "      <td>2018-03-01</td>\n",
       "      <td>5.918182e+07</td>\n",
       "      <td>475177.48</td>\n",
       "      <td>7.900095e+06</td>\n",
       "      <td>1.198333e+06</td>\n",
       "      <td>2.632447e+07</td>\n",
       "      <td>2.950648e+06</td>\n",
       "      <td>6051561.02</td>\n",
       "      <td>1.040821e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>10</th>\n",
       "      <td>2018-02-01</td>\n",
       "      <td>2.292138e+07</td>\n",
       "      <td>33232.95</td>\n",
       "      <td>5.459177e+05</td>\n",
       "      <td>7.571446e+04</td>\n",
       "      <td>2.235774e+06</td>\n",
       "      <td>2.189156e+05</td>\n",
       "      <td>1393948.47</td>\n",
       "      <td>2.742488e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>11</th>\n",
       "      <td>2018-01-01</td>\n",
       "      <td>3.653873e+07</td>\n",
       "      <td>54305.20</td>\n",
       "      <td>5.926632e+05</td>\n",
       "      <td>8.667045e+04</td>\n",
       "      <td>1.759451e+06</td>\n",
       "      <td>2.981461e+05</td>\n",
       "      <td>2607776.07</td>\n",
       "      <td>4.193774e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>12</th>\n",
       "      <td>2017-12-01</td>\n",
       "      <td>4.292283e+07</td>\n",
       "      <td>71600.17</td>\n",
       "      <td>7.969305e+05</td>\n",
       "      <td>6.914559e+04</td>\n",
       "      <td>2.213103e+06</td>\n",
       "      <td>3.141204e+05</td>\n",
       "      <td>3259747.23</td>\n",
       "      <td>4.964748e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>13</th>\n",
       "      <td>2017-11-01</td>\n",
       "      <td>5.838217e+07</td>\n",
       "      <td>94993.76</td>\n",
       "      <td>1.581530e+06</td>\n",
       "      <td>1.681418e+05</td>\n",
       "      <td>4.257594e+06</td>\n",
       "      <td>6.170949e+05</td>\n",
       "      <td>5447184.43</td>\n",
       "      <td>7.054871e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>14</th>\n",
       "      <td>2017-10-01</td>\n",
       "      <td>8.226882e+07</td>\n",
       "      <td>145925.31</td>\n",
       "      <td>2.824786e+06</td>\n",
       "      <td>1.665226e+05</td>\n",
       "      <td>4.290843e+06</td>\n",
       "      <td>7.665888e+05</td>\n",
       "      <td>6152868.25</td>\n",
       "      <td>9.661636e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>15</th>\n",
       "      <td>2017-09-01</td>\n",
       "      <td>1.010081e+08</td>\n",
       "      <td>242194.37</td>\n",
       "      <td>5.581352e+06</td>\n",
       "      <td>3.530425e+05</td>\n",
       "      <td>7.833349e+06</td>\n",
       "      <td>1.574780e+06</td>\n",
       "      <td>5792065.80</td>\n",
       "      <td>1.223849e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>16</th>\n",
       "      <td>2017-08-01</td>\n",
       "      <td>1.049504e+08</td>\n",
       "      <td>332922.02</td>\n",
       "      <td>7.229410e+06</td>\n",
       "      <td>5.440766e+05</td>\n",
       "      <td>1.376039e+07</td>\n",
       "      <td>2.323304e+06</td>\n",
       "      <td>5081714.64</td>\n",
       "      <td>1.342222e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>17</th>\n",
       "      <td>2017-07-01</td>\n",
       "      <td>1.116729e+08</td>\n",
       "      <td>913425.95</td>\n",
       "      <td>1.371805e+07</td>\n",
       "      <td>1.357779e+06</td>\n",
       "      <td>4.257757e+07</td>\n",
       "      <td>6.627300e+06</td>\n",
       "      <td>6691694.17</td>\n",
       "      <td>1.835587e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>18</th>\n",
       "      <td>2017-06-01</td>\n",
       "      <td>1.051463e+08</td>\n",
       "      <td>2045163.59</td>\n",
       "      <td>1.963593e+07</td>\n",
       "      <td>2.639778e+06</td>\n",
       "      <td>8.283230e+07</td>\n",
       "      <td>1.242242e+07</td>\n",
       "      <td>7155138.87</td>\n",
       "      <td>2.318770e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>19</th>\n",
       "      <td>2017-05-01</td>\n",
       "      <td>9.185035e+07</td>\n",
       "      <td>3606141.82</td>\n",
       "      <td>2.027552e+07</td>\n",
       "      <td>3.185962e+06</td>\n",
       "      <td>1.014605e+08</td>\n",
       "      <td>1.596195e+07</td>\n",
       "      <td>8145781.12</td>\n",
       "      <td>2.444862e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>20</th>\n",
       "      <td>2017-04-01</td>\n",
       "      <td>5.363586e+07</td>\n",
       "      <td>1285599.49</td>\n",
       "      <td>9.197868e+06</td>\n",
       "      <td>1.554864e+06</td>\n",
       "      <td>4.880687e+07</td>\n",
       "      <td>6.214964e+06</td>\n",
       "      <td>6682161.49</td>\n",
       "      <td>1.273782e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>21</th>\n",
       "      <td>2017-03-01</td>\n",
       "      <td>4.078967e+07</td>\n",
       "      <td>390486.57</td>\n",
       "      <td>3.397838e+06</td>\n",
       "      <td>3.172065e+05</td>\n",
       "      <td>1.488979e+07</td>\n",
       "      <td>1.319399e+06</td>\n",
       "      <td>3904656.82</td>\n",
       "      <td>6.500904e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>22</th>\n",
       "      <td>2017-02-01</td>\n",
       "      <td>3.467502e+07</td>\n",
       "      <td>209643.87</td>\n",
       "      <td>1.519446e+06</td>\n",
       "      <td>1.481581e+05</td>\n",
       "      <td>5.929509e+06</td>\n",
       "      <td>6.876975e+05</td>\n",
       "      <td>2584035.90</td>\n",
       "      <td>4.575351e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>23</th>\n",
       "      <td>2017-01-01</td>\n",
       "      <td>2.047156e+07</td>\n",
       "      <td>39434.76</td>\n",
       "      <td>5.967440e+05</td>\n",
       "      <td>4.816463e+04</td>\n",
       "      <td>1.213749e+06</td>\n",
       "      <td>2.389731e+05</td>\n",
       "      <td>1781773.46</td>\n",
       "      <td>2.439040e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>24</th>\n",
       "      <td>2016-12-01</td>\n",
       "      <td>3.546668e+07</td>\n",
       "      <td>84350.57</td>\n",
       "      <td>1.234900e+06</td>\n",
       "      <td>5.211896e+04</td>\n",
       "      <td>1.558634e+06</td>\n",
       "      <td>2.937372e+05</td>\n",
       "      <td>3504367.98</td>\n",
       "      <td>4.219479e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>25</th>\n",
       "      <td>2016-11-01</td>\n",
       "      <td>4.780625e+07</td>\n",
       "      <td>106291.23</td>\n",
       "      <td>1.473418e+06</td>\n",
       "      <td>8.283582e+04</td>\n",
       "      <td>2.758827e+06</td>\n",
       "      <td>5.129902e+05</td>\n",
       "      <td>4975519.21</td>\n",
       "      <td>5.771613e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>26</th>\n",
       "      <td>2016-10-01</td>\n",
       "      <td>6.339722e+07</td>\n",
       "      <td>179015.23</td>\n",
       "      <td>2.543814e+06</td>\n",
       "      <td>1.304841e+05</td>\n",
       "      <td>3.641803e+06</td>\n",
       "      <td>6.909120e+05</td>\n",
       "      <td>4600717.78</td>\n",
       "      <td>7.518397e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>27</th>\n",
       "      <td>2016-09-01</td>\n",
       "      <td>6.864724e+07</td>\n",
       "      <td>210456.69</td>\n",
       "      <td>3.092898e+06</td>\n",
       "      <td>1.687248e+05</td>\n",
       "      <td>4.632818e+06</td>\n",
       "      <td>9.305139e+05</td>\n",
       "      <td>4642681.07</td>\n",
       "      <td>8.232534e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>28</th>\n",
       "      <td>2016-08-01</td>\n",
       "      <td>7.610885e+07</td>\n",
       "      <td>316467.14</td>\n",
       "      <td>4.389863e+06</td>\n",
       "      <td>2.725540e+05</td>\n",
       "      <td>8.956868e+06</td>\n",
       "      <td>1.581022e+06</td>\n",
       "      <td>4151326.68</td>\n",
       "      <td>9.577695e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>29</th>\n",
       "      <td>2016-07-01</td>\n",
       "      <td>7.832954e+07</td>\n",
       "      <td>932728.10</td>\n",
       "      <td>7.384969e+06</td>\n",
       "      <td>7.611593e+05</td>\n",
       "      <td>2.260036e+07</td>\n",
       "      <td>4.088321e+06</td>\n",
       "      <td>5412185.06</td>\n",
       "      <td>1.195093e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>30</th>\n",
       "      <td>2016-06-01</td>\n",
       "      <td>7.693264e+07</td>\n",
       "      <td>2184985.33</td>\n",
       "      <td>1.085946e+07</td>\n",
       "      <td>1.728789e+06</td>\n",
       "      <td>4.640197e+07</td>\n",
       "      <td>8.004563e+06</td>\n",
       "      <td>5694825.13</td>\n",
       "      <td>1.518072e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>31</th>\n",
       "      <td>2016-05-01</td>\n",
       "      <td>5.812696e+07</td>\n",
       "      <td>2059879.80</td>\n",
       "      <td>9.912802e+06</td>\n",
       "      <td>1.618362e+06</td>\n",
       "      <td>4.777690e+07</td>\n",
       "      <td>7.474422e+06</td>\n",
       "      <td>5469360.60</td>\n",
       "      <td>1.324387e+08</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>32</th>\n",
       "      <td>2016-04-01</td>\n",
       "      <td>3.762602e+07</td>\n",
       "      <td>1034992.53</td>\n",
       "      <td>4.687913e+06</td>\n",
       "      <td>7.582068e+05</td>\n",
       "      <td>2.432917e+07</td>\n",
       "      <td>3.435257e+06</td>\n",
       "      <td>5253619.06</td>\n",
       "      <td>7.712518e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>33</th>\n",
       "      <td>2016-03-01</td>\n",
       "      <td>2.952610e+07</td>\n",
       "      <td>352013.31</td>\n",
       "      <td>1.204574e+06</td>\n",
       "      <td>2.461068e+05</td>\n",
       "      <td>6.656382e+06</td>\n",
       "      <td>7.467091e+05</td>\n",
       "      <td>3481194.46</td>\n",
       "      <td>4.221308e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>34</th>\n",
       "      <td>2016-02-01</td>\n",
       "      <td>1.500135e+07</td>\n",
       "      <td>96979.48</td>\n",
       "      <td>4.491994e+05</td>\n",
       "      <td>3.619385e+04</td>\n",
       "      <td>6.939075e+05</td>\n",
       "      <td>1.091081e+05</td>\n",
       "      <td>1274810.96</td>\n",
       "      <td>1.766155e+07</td>\n",
       "    </tr>\n",
       "    <tr>\n",
       "      <th>35</th>\n",
       "      <td>2016-01-01</td>\n",
       "      <td>2.107822e+07</td>\n",
       "      <td>108412.71</td>\n",
       "      <td>6.190420e+05</td>\n",
       "      <td>4.967025e+04</td>\n",
       "      <td>4.828890e+05</td>\n",
       "      <td>1.132847e+05</td>\n",
       "      <td>1562393.95</td>\n",
       "      <td>2.401391e+07</td>\n",
       "    </tr>\n",
       "  </tbody>\n",
       "</table>\n",
       "</div>"
      ],
      "text/plain": [
       "           时间         灭鼠杀虫剂       电蚊香套装      盘香灭蟑香蚊香盘         蚊香加热器  \\\n",
       "0  2018-12-01  5.256763e+07    50204.53  9.285543e+05  8.684917e+04   \n",
       "1  2018-11-01  7.175250e+07    38692.61  1.801319e+06  1.938744e+05   \n",
       "2  2018-10-01  1.136548e+08   106531.29  4.171283e+06  3.156395e+05   \n",
       "3  2018-09-01  1.440261e+08   105666.63  6.784500e+06  4.573664e+05   \n",
       "4  2018-08-01  1.540426e+08   201467.03  1.070968e+07  7.465131e+05   \n",
       "5  2018-07-01  1.480032e+08   438635.29  1.658918e+07  1.871757e+06   \n",
       "6  2018-06-01  1.359438e+08   953749.78  2.352639e+07  3.641026e+06   \n",
       "7  2018-05-01  1.241642e+08  1238967.37  2.811858e+07  5.032467e+06   \n",
       "8  2018-04-01  7.509661e+07   841051.93  1.642034e+07  3.130513e+06   \n",
       "9  2018-03-01  5.918182e+07   475177.48  7.900095e+06  1.198333e+06   \n",
       "10 2018-02-01  2.292138e+07    33232.95  5.459177e+05  7.571446e+04   \n",
       "11 2018-01-01  3.653873e+07    54305.20  5.926632e+05  8.667045e+04   \n",
       "12 2017-12-01  4.292283e+07    71600.17  7.969305e+05  6.914559e+04   \n",
       "13 2017-11-01  5.838217e+07    94993.76  1.581530e+06  1.681418e+05   \n",
       "14 2017-10-01  8.226882e+07   145925.31  2.824786e+06  1.665226e+05   \n",
       "15 2017-09-01  1.010081e+08   242194.37  5.581352e+06  3.530425e+05   \n",
       "16 2017-08-01  1.049504e+08   332922.02  7.229410e+06  5.440766e+05   \n",
       "17 2017-07-01  1.116729e+08   913425.95  1.371805e+07  1.357779e+06   \n",
       "18 2017-06-01  1.051463e+08  2045163.59  1.963593e+07  2.639778e+06   \n",
       "19 2017-05-01  9.185035e+07  3606141.82  2.027552e+07  3.185962e+06   \n",
       "20 2017-04-01  5.363586e+07  1285599.49  9.197868e+06  1.554864e+06   \n",
       "21 2017-03-01  4.078967e+07   390486.57  3.397838e+06  3.172065e+05   \n",
       "22 2017-02-01  3.467502e+07   209643.87  1.519446e+06  1.481581e+05   \n",
       "23 2017-01-01  2.047156e+07    39434.76  5.967440e+05  4.816463e+04   \n",
       "24 2016-12-01  3.546668e+07    84350.57  1.234900e+06  5.211896e+04   \n",
       "25 2016-11-01  4.780625e+07   106291.23  1.473418e+06  8.283582e+04   \n",
       "26 2016-10-01  6.339722e+07   179015.23  2.543814e+06  1.304841e+05   \n",
       "27 2016-09-01  6.864724e+07   210456.69  3.092898e+06  1.687248e+05   \n",
       "28 2016-08-01  7.610885e+07   316467.14  4.389863e+06  2.725540e+05   \n",
       "29 2016-07-01  7.832954e+07   932728.10  7.384969e+06  7.611593e+05   \n",
       "30 2016-06-01  7.693264e+07  2184985.33  1.085946e+07  1.728789e+06   \n",
       "31 2016-05-01  5.812696e+07  2059879.80  9.912802e+06  1.618362e+06   \n",
       "32 2016-04-01  3.762602e+07  1034992.53  4.687913e+06  7.582068e+05   \n",
       "33 2016-03-01  2.952610e+07   352013.31  1.204574e+06  2.461068e+05   \n",
       "34 2016-02-01  1.500135e+07    96979.48  4.491994e+05  3.619385e+04   \n",
       "35 2016-01-01  2.107822e+07   108412.71  6.190420e+05  4.967025e+04   \n",
       "\n",
       "             蚊香液           蚊香片       防霉防蛀片           总金额  \n",
       "0   3.081492e+06  4.268126e+05  3958717.58  6.110026e+07  \n",
       "1   5.543204e+06  7.766270e+05  6678677.55  8.678489e+07  \n",
       "2   7.814546e+06  1.032414e+06  8541153.59  1.356363e+08  \n",
       "3   1.065497e+07  1.566652e+06  8825870.43  1.724211e+08  \n",
       "4   1.783558e+07  2.617149e+06  6320153.44  1.924731e+08  \n",
       "5   3.887792e+07  6.209040e+06  6302595.06  2.182924e+08  \n",
       "6   7.649909e+07  1.248492e+07  7047206.98  2.600962e+08  \n",
       "7   1.050396e+08  1.530972e+07  7942340.44  2.868459e+08  \n",
       "8   6.254165e+07  7.954875e+06  7031364.60  1.730164e+08  \n",
       "9   2.632447e+07  2.950648e+06  6051561.02  1.040821e+08  \n",
       "10  2.235774e+06  2.189156e+05  1393948.47  2.742488e+07  \n",
       "11  1.759451e+06  2.981461e+05  2607776.07  4.193774e+07  \n",
       "12  2.213103e+06  3.141204e+05  3259747.23  4.964748e+07  \n",
       "13  4.257594e+06  6.170949e+05  5447184.43  7.054871e+07  \n",
       "14  4.290843e+06  7.665888e+05  6152868.25  9.661636e+07  \n",
       "15  7.833349e+06  1.574780e+06  5792065.80  1.223849e+08  \n",
       "16  1.376039e+07  2.323304e+06  5081714.64  1.342222e+08  \n",
       "17  4.257757e+07  6.627300e+06  6691694.17  1.835587e+08  \n",
       "18  8.283230e+07  1.242242e+07  7155138.87  2.318770e+08  \n",
       "19  1.014605e+08  1.596195e+07  8145781.12  2.444862e+08  \n",
       "20  4.880687e+07  6.214964e+06  6682161.49  1.273782e+08  \n",
       "21  1.488979e+07  1.319399e+06  3904656.82  6.500904e+07  \n",
       "22  5.929509e+06  6.876975e+05  2584035.90  4.575351e+07  \n",
       "23  1.213749e+06  2.389731e+05  1781773.46  2.439040e+07  \n",
       "24  1.558634e+06  2.937372e+05  3504367.98  4.219479e+07  \n",
       "25  2.758827e+06  5.129902e+05  4975519.21  5.771613e+07  \n",
       "26  3.641803e+06  6.909120e+05  4600717.78  7.518397e+07  \n",
       "27  4.632818e+06  9.305139e+05  4642681.07  8.232534e+07  \n",
       "28  8.956868e+06  1.581022e+06  4151326.68  9.577695e+07  \n",
       "29  2.260036e+07  4.088321e+06  5412185.06  1.195093e+08  \n",
       "30  4.640197e+07  8.004563e+06  5694825.13  1.518072e+08  \n",
       "31  4.777690e+07  7.474422e+06  5469360.60  1.324387e+08  \n",
       "32  2.432917e+07  3.435257e+06  5253619.06  7.712518e+07  \n",
       "33  6.656382e+06  7.467091e+05  3481194.46  4.221308e+07  \n",
       "34  6.939075e+05  1.091081e+05  1274810.96  1.766155e+07  \n",
       "35  4.828890e+05  1.132847e+05  1562393.95  2.401391e+07  "
      ]
     },
     "execution_count": 33,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "df.reset_index()"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.8"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 4
}
